package io.gitee.twoke.generator.engine.impl.generate.impl;

import io.gitee.twoke.generator.engine.impl.AbstractQuery;
import io.gitee.twoke.generator.engine.impl.Page;
import io.gitee.twoke.generator.engine.impl.generate.DataTable;
import io.gitee.twoke.generator.engine.impl.generate.DataTableQuery;
import io.gitee.twoke.generator.engine.impl.interceptor.CommandContext;
import io.gitee.twoke.generator.engine.impl.interceptor.CommandExecutor;

import java.util.List;

public class DataTableQueryImpl
    extends AbstractQuery<DataTableQuery, DataTable>
    implements DataTableQuery
{

    private String id;
    private String tableName;

    public ResultType getResultType() {
        return resultType;
    }


    public DataTableQueryImpl(CommandExecutor commandExecutor) {
        super(commandExecutor);
    }

    public DataTableQueryImpl(CommandExecutor commandExecutor, String databaseType) {
        super(commandExecutor);
        this.databaseType = databaseType;
    }

    @Override
    public long executeCount(CommandContext commandContext) {
        return  commandContext.getDataTableEntityManager().findDataTableCountByQueryCriteria(this);
    }

    @Override
    public List<DataTable> executeList(CommandContext commandContext, Page page) {
        return commandContext.getDataTableEntityManager().findDataTablesByQueryCriteria(this);
    }

    @Override
    public DataTableQuery id(String id) {
        this.id = id;
        return this;
    }

    @Override
    public DataTableQuery tableName(String tableName) {
        this.tableName = tableName;
        return this;
    }
}
